<template>
	<view class="page-map">
		<map id="myMap" :scale="18" style="width:750upx;height:90vh" show-location="false" :polygons="polygons"
			:markers="markers" @tap='mapTap' @updated="mapEnd" :latitude="latitude" :longitude="longitude"
			:polyline="polyline" @regionchange='regionchange' @markertap='markertap'>
		</map>
	</view>
</template>

<script>
	import QQMapWX from "@/utils/qqmap-wx-jssdk.min.js"
	var qqmapsdk = new QQMapWX({ // key: '申请的key'
		key: 'V4OBZ-NAYK6-D2OSX-MXVMI-3PXVF-GDFPJ'
	});
	export default {
		data() {
			return {
				polygons: [],
				markers: [],
				indexType: 2,
				latitude: 0,
				longitude: 0,
				polyline: [],
			}
		},
		onLoad(options) {

		},
		mounted(){
			var that = this;
			that.indexType = 1;
			that.mapCtx = uni.createMapContext("myMap", that)
		},
		methods: {
			load() {
				var that = this
				var location = uni.getStorageSync('aldLocationInfo')
				uni.getLocation({
					type: 'gcj02',
					success: function(res) {
						that.latitude = res.latitude;
						that.longitude = res.longitude;
						uni.setStorageSync('aldLocationInfo', res)
						// that.getCar(res.latitude, res.longitude)
						// that.getPlace(res.latitude, res.longitude)
					},
					fail(err) {
						if (location) {
							that.latitude = location.latitude
							that.longitude = location.longitude
						} else {
							that.modalName = 'noAdress'
						}
					}
				});
			},
			mapTap() {
				if (this.indexType == 2) {
					this.indexType = 1
				}
			},
			mapEnd() {
				console.log('地图加载完毕')
			},
			regionchange(e) {},
			markertap(e) {}
		}
	}
</script>

<style scoped lang="scss">

</style>